<template>
	<view class="tp-bgf" style="height: 1026rpx;">
		<!-- 顶部 S-->
		<view class="dasangTop align_center  flex flex_start tp-pt20">
			<view class=" flex align_center tp-ml30" style="width: 80rpx;height: 80rpx;">
				<image style="width: 56rpx;height: 56rpx;border-radius: 50%;" :src="customerAvater" mode=""></image>
			</view>
			<view class="flex tp-fyl">
				<text class="tp-fz24" style="margin-bottom: 5rpx;">{{customerName}}</text>
				<text class="tp-fz22 tp-fc999" >您的支持是我继续创作的动力</text>
			</view>
		</view>
		<!-- 顶部 E-->
		<!-- 打赏 S-->
		<view class="dasang tp-ptb0lr30 tp-mt20 ">
			<text class="tp-fz28">打赏</text>
			<text class="tp-fc999">(当前积分 <text class="tp-fz24 tp-red">{{jifen}}</text>分)</text>
		</view>
		<view class="dasangjf tp-ptb0lr20 ">
			<input type="number" placeholder="请输入打赏积分个数" v-model="dsjifen"></input>
		</view>
		<!-- 打赏 E-->
		<view class="dasang tp-ptb0lr30 tp-mt20 ">
			<text class="tp-fz28">评论</text>
		</view>
		<view class="dasangjf tp-ptb0lr20 ">
			<input placeholder="请输入评论内容" v-model.trim="pinglun"></input>
		</view>
		<view class="queding" @click="activityReWard">
			<text class="tp-fz32 tp-fcF">打赏并评论</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id:'',
				jifen:'',
				dsjifen:'',//输入的打赏积分
				pinglun:'',//评论
				customerName:'',//名字
				customerAvater:'',//头像
			};
		},
		onLoad(opt) {
			console.log(opt)
			 this.id = opt.id
			 this.customerName = opt.customerName
			 this.customerAvater = opt.customerAvater
		},
		onShow() {
			this.getjifen()
		},
		// 下拉刷新
		onPullDownRefresh() {
			this.getjifen()
		},
		methods:{
			//积分查询
			getjifen(){
				this.$http.get(this.$api.customerInfo).then(res => {
					uni.stopPullDownRefresh();
					if(res.code ==200){
						this.jifen = res.data.rewardPoint
					}
				})
			},
			//打赏并评论
			activityReWard(){
				
				if(this.dsjifen==''){
					uni.showToast({
						title: '打赏积分不能为空',
						icon: 'none'
					})
					return
				}
				if(this.pinglun==''){
					uni.showToast({
						title: '评论不能为空',
						icon: 'none'
					})
					return
				}
				this.dsjifen=parseInt(this.dsjifen); // 234(s); // 234
				this.jifen=parseInt(this.jifen); // 234(s); // 234
				console.log(this.dsjifen,this.jifen)
				if(this.dsjifen>this.jifen){
					uni.showToast({
						title: '打赏积分不能大于当前积分',
						icon: 'none'
					})
					return
				}
				let param = {
					jifen: this.dsjifen, //输入的打赏积分
					commentContent: this.pinglun, //评论
					glId: this.id, //	此景区id
				}
				this.$http.post(this.$api.activityReWard,param).then(res => {
					if(res.code == 200){
						uni.showToast({
							title: '操作成功',
							icon: 'none'
						})
						uni.navigateBack({  //uni.navigateTo跳转的返回，默认1为返回上一级
								delta: 1
								})
					}
				})
			},
		},
	}
</script>

<style lang="scss">
.dasangTop{
	width: 100%;
	height: 80rpx;
}
.dasang{
	width: 100%;
	height: 40rpx;
	margin-bottom: 30rpx;
}
.dasangjf{
	margin: 0 auto;
	width: 690rpx;
	height: 88rpx;
	background: #F5F5F5;
	border-radius: 8rpx;
	line-height: 88rpx;
	box-sizing: border-box;
	margin-bottom: 30rpx;
}
.queding{
	line-height: 88rpx;
	text-align: center;
	margin: 0 auto;
	width: 610rpx;
	height: 88rpx;
	background: #00B4FF;
	border-radius: 44rpx;
	margin-top: 80rpx;
}
</style>
